<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>

<style>
    .Completed,.status_2{color: #c00;}
    .Refunded,.status_1{color: #f60;}
    .Pending{color: #36c;}
    .Unclaimed,.status_3{color: #666;}
</style>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action="/admini/manageuser/paylog/"  method="get" style="margin:0px" id="form1">
        <div class="search">
            <div class="soubox">
                <input type="text" id="quick" name="quick" value="<?php echo $this->quick?$this->quick:"";?>" placeholder="输入单号/仓库号/用户名等"/>
                <input type="hidden" id="dateinbegin" name="dateinbegin" value="<?php echo $this->dateinbegin?$this->dateinbegin:"";?>"/>
                <input type="hidden" id="dateinend" name="dateinend" value="<?php echo $this->dateinend?$this->dateinend:"";?>" />
                <input type="hidden" id="paypalStatus" name="paypalStatus" value="<?php echo $this->paypalStatus?$this->paypalStatus:"";?>" />
                <input type="hidden" id="status" name="status" value="<?php echo $this->status===""?"":$this->status;?>" />
            </div>
            <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
        </div>

        <div class="timebox">
            <div class="ad_time">
                <div class="timezdy">
                    <div class="timeselect2">
                        <span>选择时间</span>
                    </div>
                </div>
                <div class="timefw">
                    <div class="time">
                        <!--点击后悬停样式为：<div class="timeselect t_on">-->
                        <div class="timeselect"  id="stime">
                            <span id="stimeval"><?php echo $this->starttime?$this->starttime:date("Y-m-d",mktime(0,0,0,date("m"),date("d")-90,date("Y")));?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                    <div class="timezhi">
                        <span>至</span>
                    </div>
                    <div class="time" >
                        <div class="timeselect" id="etime">
                            <span id="etimeval"><?php echo $this->endtime?$this->endtime:date("Y-m-d");?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="timeok">
                <a href="javascript:$('#form1').submit();">确定</a>
            </div>
        </div>
        </form>
    </div>
</div>
<div  class="biaoge">
	<div class="biaotbody">
            	<table>
                    <tr>
                    	<th class="li205">
                            <div class="lijz"><input name="checkall" type="checkbox" id="checkall" value=""></div>
                        </th>
                    	<th class="li9">
                            <div class="lileft">交易流水号</div>
                        </th>
                    	<th class="li9">
                            <div class="lijz">交易时间</div>
                        </th>
                    	<th class="li9">
                            <div class="lijz">Paypal用户名</div>
                        </th>
                    	<th class="li10">
                            <div class="lijz">Paypal邮箱</div>
                        </th>
                        <th class="li7">
                            <div class="lijz">交易总金额</div>
                        </th>
                    	<th class="li7">
                            <div class="lijz">交易手续费</div>
                        </th>
                        <th class="li7">
                            <div class="lijz">交易实际金额</div>
                        </th>
                    	<th class="li7">
                            <div class="biaoxiala" style='margin-left: 35px;'>
                                <div class="lixiala">
                                    <span>Paypal状态</span>
                                    <i></i>
                                </div>
                                <div class="biaoxllb" style="display:none;">
                                    <ul>
                                    	<?php foreach ($this->allPayStatus as $psykey => $payStatusName) { ?>
                                            <li><a href="javascript:setProperty('paypalStatus','<?php echo $psykey; ?>')"><?php echo $payStatusName; ?></a></li>
                                        <?php } ?>
                                    </ul>
                                </div>
                            </div>
                        </th>
                    	<th class="li7">
                            <div class="biaoxiala" style='margin-left: 40px;'>
                                <div class="lixiala">
                                    <span>状态</span>
                                    <i></i>
                                </div>
                                <div class="biaoxllb" style="display:none;">
                                    <ul>
                                    	<?php foreach ($this->allStatus as $key => $statusName) { ?>
                                            <li><a href="javascript:setProperty('status',<?php echo $key; ?>)"><?php echo $statusName; ?></a></li>
                                        <?php } ?>
                                    </ul>
                                </div>
                            </div>
                        </th>
                    	<th class="li6"><div class="lijz">操作/操作人</div></th>
                    </tr>
                </table>
            </div>
           <?php if($this->paypalStatus || ($this->status !== "" && $this->status !== null)){?>
            <div class="xzinfo">
            	<ul>
                    <?php if($this->paypalStatus){ ?><li><div class="xzinfobox"><span><?php echo $this->allPayStatus["$this->paypalStatus"];?></span><a href="javascript:removeset('paypalStatus')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->status === "" && $this->status !== null){}else{ ?><li><div class="xzinfobox"><span><?php echo $this->allStatus["$this->status"];?></span><a href="javascript:removeset('status')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                </ul>
            </div>
            <div class="table" style='margin-top:0px;'>
           <?php } else {?>
            <div class="table">
           <?php } ?>
                <table>
                <?php 
                    if( $this->paylogList){
                    foreach ($this->paylogList as $key => $Item) {?>
                    	<tr height='50px'>
                            <td class="li205"><div class="lijz"><input type="checkbox" id="chk<?php echo $Item->id; ?>" name="ID" /></div></td>
                            <td class="li9">
                                <div class="lileft"><?php echo $Item->TxnId;?></div>
                            </td>
                            <td class="li9"><div class="lijz"><?php echo $Item->DateCreated;?></div></td>
                            <td class="li9"><div class="lijz"><?php echo $Item->PaypalName;?></div></td>
                            <td class="li10"><div class="lijz"><?php echo $Item->PaypalEmail;?></div></td>
                            <td class="li7"><div class="lijz"><?php echo $Item->Amount;?></div></td>
                            <td class="li7"><div class="lijz"><?php echo $Item->FeeAmt;?></div></td>
                            <td class="li7"><div class="lijz"><?php echo ($Item->Amount+$Item->FeeAmt);?></div></td>
                            <td class="li7"><div class="lijz <?php echo $Item->PaypalStatus;?>"><?php echo $Item->PaypalStatusName?$Item->PaypalStatusName:($Item->PaypalStatus);?></div></td>
                            <td class="li7"><div class="lijz <?php echo "status_".$Item->Status;?>"><?php echo $Item->StatusName;?></div></td>
                            <td class="li6"><?php if($Item->IsDel == 1){ ?>
                                    <div class="lijz"><?php echo $Item->Operator?$Item->Operator."<br>已删除":"已删除";?></div>
                                <?php } else {?>
                                <?php if($Item->Status > Application_Model_PaypalLog::Status_Default){ ?>
                                    <div class="lijz"><?php echo $Item->Operator;?></div>
                                <?php } else {?>
                                <div class="lixlnav">
                                    <a class="xlnavxq" href="javascript:void(0)" >默认</a>
                                    <div class="xlnavlistbox" >
                                        <a class="xlnavsj" href="javascript:void(0)"><i></i></a>
                                        <div class="xlnavlist" style="display:none;width: 110px;">
                                            <ul>
                                                <?php foreach ($this->allStatus as $key => $statusName) {
                                                        if($key > Application_Model_PaypalLog::Status_Default){
                                                    ?>
                                                <li><a href="javascript:void(0);" class='setStatus' name='<?php echo $key; ?>' i='<?php echo $Item->Id;?>'>设为<?php echo $statusName; ?></a></li>
                                                <?php } }?>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            <?php } } ?>
                            </td>
                        </tr>
                <?php } } else { echo '<div class="tablebox">暂时无数据</div>';}?>
                </table>
            </div>
    </div>
<div class="toolbar">
<?php
echo $this->partial('paging.phtml', array("pages" => $this->paylogAll,"pamas"=>"quick=$this->quick&dateinbegin=$this->dateinbegin&dateinend=$this->dateinend&paypalStatus=$this->paypalStatus&status=$this->status"));        
?>
</div>    
<script>
    $('.soubox label').click(function(){
            $(this).parent().find('input').focus();
    });
    $(".timezdy").click(function(){
        $(".timezdy .timeselect2").attr("class","timeselect2 timeon");
        $(".timeslelct_xl").show();
    });
    $(".timezdy").mouseleave(function(){
       $(".timeselect2").attr("class","timeselect2");
       $(".timeslelct_xl").hide();
    });
    $("#stime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'stimeval',vel:'dateinbegin',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
        }});
    });
    $("#etime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'etimeval',vel:'dateinend',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
        }});
    });
    $(".lixiala").click(function(){
        $(".lixiala").attr("class","lixiala");
        $(".lixiala").next("div").hide();
    
        $(this).attr("class","lixiala bton");
        $(this).next("div").show();
    });

    $(document).bind("click",function(e){
        var target  = $(e.target);
        if(target.closest(".biaoxiala").length == 0){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").hide();
        }
        if(target.closest("#stime").length == 0){
            $("#stime").attr("class","timeselect");
        }
        if(target.closest("#etime").length == 0){
            $("#etime").attr("class","timeselect");
        }
    });
    $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").show();
    });
    $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").hide();
    });
    function setProperty(property,value)
    {
        $("#form1 #"+property).val(value);
        $("#form1").submit();
    }
    function removeset(property)
    {
        $("#form1 #"+property).val("");
        $("#form1").submit();
    }
    $(".setStatus").click(function(){
       var status = $(this).attr("name");
       var statusName = $(this).text();
       var id = $(this).attr("i");
       if(confirm("您确定把该条Paypal交易记录"+statusName,"提示信息")){   
            $.ajax({
                 type: 'POST',
                 url: '/admini/manageuser/setstatus/id/'+id+"/status/"+status,
                 success: function(data) {
                        if(data == 1){
                            alert("设置成功！");
                        }else{
                            alert("出现未知错误！");
                        }
                        location.reload();
                    }
               });
       }
    });
</script>
